package com.feihao.zhou.workTest.demo01;

import java.util.Iterator;
import java.util.TreeSet;

/**
 * 2.分析以下需求，并用代码实现：
 (1)定义一个员工类Employee，包含三个属性：姓名(String name)、
 年龄(int age)、工资(int salary)
 (2)创建5个对象装入TreeSet，按照工资从高到底排序输出结果(工资相同，
 按照年龄从低到高，工资和年龄都相同，
 按照姓名字典顺序排列，但是不能去重(姓名、年龄、工资都相同))
 */
public class TestMain {
    public static void main(String[] args) {
        //创建employee对象：
        Employee employee1= new Employee("zhangsan",16,8000);
        Employee employee6= new Employee("zhangsan",16,8000);
        Employee employee2= new Employee("lisi",33,40000);
        Employee employee3= new Employee("wangwu",22,12000);
        Employee employee4= new Employee("zhaoliu",13,2000);
        Employee employee5= new Employee("aianqi",33,40000);

        //创建TreeSet集合：
        TreeSet<Employee> treeSet = new TreeSet<>();
        treeSet.add(employee1);
        treeSet.add(employee2);
        treeSet.add(employee3);
        treeSet.add(employee4);
        treeSet.add(employee5);
        treeSet.add(employee6);

        Iterator<Employee> iterator = treeSet.iterator();
        while(iterator.hasNext()){
            Employee e = iterator.next();
            System.out.println(e);
        }
    }
}
